home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Programming / Complete Applications / Screen Savers / ZoomIdle (C) / ZoomRect.c < prev   
Encoding:
Text File  |  1986-07-10  |  2.5 KB  |  93 lines  |  [TEXT/ttxt]

  1. /* Written  5:26 am  Jul  6, 1986 by baron@runx.OZ in uiucdcsb:net.sources.mac */
  2. /* ---------- "ZoomRect() - C source" ---------- */
  3.  
  4. Here is the C source to zoomrect() - a function that produces the zooming
  5. effect found in various programs like the Finder.
  6.  
  7.  
  8. /* Jason Haines            ACSnet: baron@runx
  9.  * ElecEng Undergraduate   CSNET:  baron@runx.oz
  10.  * Australia               ARPA:   baron%runx.oz@seismo.css.gov
  11.  * 
  12.  * UUCP:
  13.  *   {enea,hplabs,mcvax,prlb2,seismo,ubc-vision,ukc}!munnari!runx.oz!baron
  14.  */
  15.  
  16. --------------------------(Cut Here)----------------------------
  17. /*
  18.  *  Title:        zoomrect.c
  19.  *  Author:        Jason Haines
  20.  *    Version:    1.0
  21.  *  Date:         July 6th 1986
  22.  *  
  23.  * Synopsis:    The function zoomrect(sourcerect,destrect,zoomSteps) produces
  24.  *                 the zoom effect found in the Finder.
  25.  *                Where:
  26.  *                         sourcerect is the source rectangle;
  27.  *                        destrect is the destination rectangle;
  28.  *                      zoomSteps is the number of intermediate rectangles
  29.  *                        displayed.
  30.  *  
  31.  *  
  32.  * Jason Haines
  33.  * 73 Davidson Avenue
  34.  * Concord NSW 2137
  35.  * AUSTRALIA
  36.  * 
  37.  * STD:  (02) 73-4444
  38.  * ISD: +61 2 73-4444
  39.  * ACSnet: baron@runx
  40.  * CSNET:  baron@runx.oz
  41.  * ARPA:   baron%runx.oz@seismo.css.gov
  42.  * JANET:  runx.oz!baron@ukc
  43.  * UUCP:   {enea,hplabs,mcvax,prlb2,seismo,ubc-vision,ukc}!munnari!runx.oz!baron
  44.  */
  45.  
  46. #include "qd.h"
  47. #include "qdvars.h"
  48.  
  49. #define MaxZoom        100
  50.  
  51. zoomrect(r1,r2,zoomSteps)
  52. rect *r1,*r2;
  53. int zoomSteps;
  54. {
  55.     int hDiff, vDiff, widDiff, htDiff;
  56.     int l, t, r, b;
  57.     int rWid, rHt;
  58.     register int i, j;
  59.     register int zIndex;
  60.     rect *rp;
  61.     static rect    zRect[MaxZoom];
  62.     penstate oldpen;
  63.     
  64.     if (zoomSteps > MaxZoom)
  65.         return(0);
  66.     getpenstate(&oldpen);
  67.     penpat(gray);
  68.     penmode(notpatxor);
  69.     zIndex = zoomSteps;
  70.     hDiff = r2->a.left - r1->a.left; /* positive if moving to right */
  71.     vDiff = r2->a.top - r1->a.top;   /* positive if moving down */
  72.     rWid = r1->a.right - r1->a.left;
  73.     rHt = r1->a.bottom - r1->a.top;
  74.     widDiff = (r2->a.right - r2->a.left) - rWid;
  75.     htDiff = (r2->a.bottom - r2->a.top) - rHt;
  76.     for ( i = 1; i < 3 ; i++)
  77.         for ( j = 1; j < zoomSteps ; j++)
  78.         {
  79.             ++zIndex;
  80.             if (zIndex >= zoomSteps)
  81.                 zIndex = 0;
  82.             rp = &zRect + zIndex;
  83.             l = r1->a.left + (hDiff * j) / zoomSteps;
  84.             t = r1->a.top + (vDiff * j) / zoomSteps;
  85.             r = l + rWid + (widDiff * j) / zoomSteps;
  86.             b = t + rHt + (htDiff * j) / zoomSteps;
  87.             setrect (rp, l, t, r, b);
  88.             framerect (rp);
  89.         }
  90.     setpenstate(&oldpen);
  91. }
  92. /* End of text from uiucdcsb:net.sources.mac */
  93.